//
//  ECUIView_CourseDetailHeader.m
//  Edu_iOS2018
//
//  Created by yanyan on 2018/2/1.
//  Copyright © 2018年 yanyan. All rights reserved.
//

#import "ECUIView_CourseDetailHeader.h"

@interface ECUIView_CourseDetailHeader() <CYTabbarViewDatasource>


@end
@implementation ECUIView_CourseDetailHeader
- (void)addSubviews
{
    [super addSubviews];

    self.backgroundColor = [UIColor whiteColor];
    
    UIView *view = [[UIView alloc]init];
    view.frame = CGRectMake(0, CGRectGetMaxY(_titleView.frame), kScreenWidth, 5);
    view.backgroundColor = [UIColor colorWithHexString:@"#f2f5f6"];
    [self addSubview:view];
}
- (CYUIView_Tabbar *)titleView
{
    if (!_titleView) {
        WeakSelf(weakSelf);

        _titleView = [[CYUIView_Tabbar alloc]initWithFrame:CGRectMake(0, 0, kScreenWidth, TABBAR_TITLE_HEIGHT)];
        _titleView.backgroundColor = [UIColor whiteColor];
        
        _titleView.indicatorAttributes = @{CYTabIndicatorColor:ECTHEMESELECTEDCOLOR,CYTabIndicatorViewHeight:@(2.0f * kPercentage),CYTabBoxBackgroundColor:ECTHEMESELECTEDCOLOR,CYTabIndicatorCornerRadius:@(kPercentage)};
        _titleView.selectedAttributes = @{NSFontAttributeName:[UIFont systemFontOfSize:13.0f * kPercentage],NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#ff6700"]};
        _titleView.selectionType = CYTabbarSelectionIndicator;
//        _titleView.needTextGradient = NO;
        _titleView.locationType = CYTabbarIndicatorLocationDown;

        _titleView.scrollEnable = NO;
        _titleView.dataSource = self;
        _titleView.indicatorEqualTitleWidth = YES;
        _titleView.block_IndexPathSelected = ^(NSIndexPath * _Nonnull indexPath) {
            if (weakSelf.block_IndexPathSelected) {
                weakSelf.block_IndexPathSelected(indexPath);
            }
            //        [weakSelf.scrollView setContentOffset:CGPointMake(kScreenWidth*indexPath.row, 0) animated:YES];
            //        [weakSelf reloadMaxOffsetY];
        };
        [self addSubview:self.titleView];
        //  分割线
        UIView *line1View = [[UIView alloc]initWithFrame:CGRectMake((kScreenWidth - 2 )/ 3.0, 10, 1, 20)];
        line1View.backgroundColor = [UIColor colorWithHexString:@"#f2f5f6"];
        [_titleView addSubview:line1View];
        UIView *line2View = [[UIView alloc]initWithFrame:CGRectMake((kScreenWidth - 2) / 3.0 * 2 + 1, CGRectGetMinY(line1View.frame), CGRectGetWidth(line1View.frame), CGRectGetHeight(line1View.frame))];
        line2View.backgroundColor = [UIColor colorWithRed:0.9255 green:0.9255 blue:0.9255 alpha:1];
        [_titleView addSubview:line2View];
    }
    return _titleView;
}
- (NSArray<NSString *> *)tabbarTitlesForTabbarView:(CYUIView_Tabbar *)tabbarView
{
    return @[@"详情",@"目录",@"评价"];
}
/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
